

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @Author wonghiu
 * @Date 2021/8/2 19:42
 * @Version 1.0.1
 */
public class shopeeThreee {
    public static void main(String[] args) {
        String str = "<name>1110</name><p><name>111</name><age>11</age></p>";
        String check = "p.name";
        String[] split = check.split("\\.");

        String pattern = "";
        for (int i = 0; i <split.length-1 ; i++) {
            pattern+="<"+split[i]+">"+".*";
        }
        pattern = pattern+"<"+split[split.length-1]+">"+"(.*)"+"</"+split[split.length-1]+">";
        Pattern r = Pattern.compile(pattern);
        Matcher m = r.matcher(str);
        if (m.find( )) {
            System.out.println(m.group(1));
        }
    }
}
